package cn.iocoder.yudao.module.promotion.service.quickcombinationactivity;

import cn.iocoder.yudao.module.promotion.api.quickcombination.dto.QuickCombinationRecordCreateReqDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.quickcombinationactivity.vo.record.QuickCombinationRecordRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.quickcombinationactivity.vo.record.QuickCombinationRecordSummary;
import cn.iocoder.yudao.module.promotion.convert.quickcombinationactivity.QuickCombinationRecordConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.quickcombinationactivity.QuickCombinationRecordDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.quickcombinationactivity.QuickCombinationRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
@Validated
public class QuickCombinationRecordServiceImpl implements QuickCombinationRecordService{

    @Resource
    private QuickCombinationRecordMapper quickCombinationRecordMapper;

    @Override
    public void createQuickCombinationRecord(QuickCombinationRecordCreateReqDTO createDTO){
        quickCombinationRecordMapper.insert(QuickCombinationRecordConvert.INSTANCE.convert(createDTO));
    }

    @Override
    public QuickCombinationRecordSummary getSummary(Collection<Long> ids){
        List<QuickCombinationRecordDO> list = quickCombinationRecordMapper.selectList(QuickCombinationRecordDO::getActivityId, ids);

        QuickCombinationRecordSummary summary = new QuickCombinationRecordSummary();
        summary.setRecordList(QuickCombinationRecordConvert.INSTANCE.convertList(list));

        return summary;
    }

    @Override
    public List<QuickCombinationRecordRespVO> getRecorrd(Long id){
        List<QuickCombinationRecordDO> list = quickCombinationRecordMapper.selectList(QuickCombinationRecordDO::getActivityId, id);

        return QuickCombinationRecordConvert.INSTANCE.convertList(list);
    }

}
